<?php
/*
 *
 */
class UserAgentManager {


    public function UserAgentManager() {
    }

    public function is_iphone() {
        $_ret = false;
        if (preg_match('/iPhone/i', $_SERVER['HTTP_USER_AGENT'])) {
            $_ret = true;
        }
        return $_ret;
    }

    public function is_ipad() {
        $_ret = false;
        if (preg_match('/iPad/i', $_SERVER['HTTP_USER_AGENT'])) {
            $_ret = true;
        }
        return $_ret;
    }

    public function is_ipod() {
        $_ret = false;
        if (preg_match('/iPod/i', $_SERVER['HTTP_USER_AGENT'])) {
            $_ret = true;
        }
        return $_ret;
    }

    public function is_ios() {
        $_ret = false;
        if ($this->is_iphone() || $this->is_ipad() || $this->is_ipod()) {
            $_ret = true;
        }
        return $_ret;
    }

    public function is_smartphone() {
        $useragents = array(
            'iPhone', // Apple iPhone
            'iPod', // Apple iPod touch
            'Android', // 1.5+ Android
            'dream', // Pre 1.5 Android
            'CUPCAKE', // 1.5+ Android
            'blackberry9500', // Storm
            'blackberry9530', // Storm
            'blackberry9520', // Storm v2
            'blackberry9550', // Storm v2
            'blackberry9800', // Torch
            'webOS', // Palm Pre Experimental
            'incognito', // Other iPhone browser
            'webmate' // Other iPhone browser
        );
        $pattern = '/' . implode('|', $useragents) . '/i';
        return preg_match($pattern, $_SERVER['HTTP_USER_AGENT']);
    }

    public function is_pc() {
        if (!$this->is_smartphone() && !$this->is_ipad()) {
            return true;
        } else {
            return false;
        }
    }
    public function is_Chrome(){
        return(eregi("chrome", $_SERVER['HTTP_USER_AGENT']));
    }

}
